<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../styles/common.css"/>
    <link rel="stylesheet" href="../styles/base.css"/>
</head>

<BODY>
<center style="">
    <div style="width: 80%;">

        <div id="table2"></div>
        <div id="pageBar2"></div>
    </div>

</center>
</body>
<script language="Javascript" src="../jqueryNicepage/js/layui.js"></script>
<script src="../layer/layer.js" charset="utf-8"></script>
<script language="Javascript" src="../jqueryNicepage/js/history.js"></script>
<script LANGUAGE="javascript">
    var check="false";
    var flage=true;
    //标准json格式 目前只支持[{a:b,c:d},{a:b,c:d}]此种格式
    var dataListObj=[];
    var json1 =window.historyList1;
    var nameList1= window.headers1 //table的列名
    var widthList1 = window.widths1//table每列的宽度
    $(function () {
        nicePage2.setCfg1({
            cont: $('#pageBar2,#pageBar'),
            table: 'table2',
            bar: 'pageBar2',
            limit: 30,
            color: '#1E9FFF',
            layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
        });

        layui.use("laypage", function() {
            var a = layui.laypage;
            var table = layui.table;
            a.render({
                elem: nicePage2.bar,
                limit: nicePage2.limt,
                theme: nicePage2.color,
                count: json1.length,
                layout: nicePage2.layout,
                jump: function(w) {
                    document.getElementById(nicePage2.table).innerHTML = function() {
                        var c = [nicePage2.returnHtml(nameList1, widthList1)],
                                d = nicePage2.returnList(json1).concat().splice(w.curr * w.limit - w.limit, w.limit);
                        layui.each(d, function(index, g) {
                            var f = nicePage2.returnTable(index+1,g);
                            c.push(f)
                        });
                        c.push(" </tbody></table></br>");
                        return c.join("")
                    }()
                }
            })

        })
    });//初始化完成
    //点击操作按钮跳转ecotabs.html;
    $(document).on("click","tbody tr .operationClick",function(e) {
        var otr=$(this).parents("tr")[0];
        var num=$(otr).find(".td0 input").val();
        var view= $(otr).find(".td1 input").val();
        window.open("ecotabs.html?num="+num+"&view="+view+"&single="+true+"&oid="+ window.ecoid);
        /*window.location.href="about:blank";
        window.opener=null;
        window.open('','_self');
        window.close();*/
    })
    //删除历史数据并重新排序；
    $(document).on("click","tbody tr .deleteItem",function(e) {
        var that=this;
        deleteTips("确定删除此行变更操作？",function(){
            var otr=$(that).parents("tr")[0];
            var num=$(otr).find(".td0 input").val();
            var view=$(otr).find(".td1 input").val();
            var url1 = "/tmECODeleteSingleData";
            var oid="oid="+window.ecoid+"&number="+num+"&view="+view;
            myAjaxHistory(url1,oid,function(str){
                if(str.result!=''&&str.result!=undefined){
                    layerFn(str.result);
                }else{
                    layerFn("删除成功");
                    $(otr).remove();
                    var $tr =$(".layui-table tbody tr");
                    if($tr.length==0){
                        var url1 = "/tmECOHistoryData";
                        var oid="oid="+encodeURIComponent(window.ecoid);
                        myAjaxHistory(url1,oid,function(str){
                            if(str.result!=''&&str.result!=undefined){
                                //layerFn(str.result);
                            }else{
                                if(str.datalist.length>0){
                                    var datArr=[];
                                    for(var datL=0;datL<str.datalist.length;datL++){
                                        var dataobj={};
                                        dataobj.number=str.datalist[datL].number;
                                        dataobj.view=str.datalist[datL].view;
                                        dataobj.state=str.datalist[datL].state;
                                        datArr.push(dataobj)
                                    }
                                    if(datArr.length==0){
                                        $(".historyDataL").empty()
                                    }else{

                                        window.historyList=datArr;
                                        //window.location.reload();
                                        window.headers1=["序号","受影响对象料号","视图","状态","编辑"]
                                        window.widths1=[100,300,200,100];
                                        $(".historyDataL").empty().load('./ecoSearchList.html');
                                    }


                                }else if(str.datalist.length==0||str.datalist==undefined){
                                    $(".historyDataL").empty()
                                }
                            }
                        });

                    }
                    for(var i=0;i< $tr.length;i++){
                        var v=i+1;
                        $($tr).eq(i).find(".serialNumber").text(v);
                    }
                }
            });
        })



    });
</script>

</html>